Skip to content

fix: don't append trailing space when selecting autocomplete group names (#3710)#3976

Open
shengxinzhe wants to merge 1 commit intoconversejs:masterfrom
shengxinzhe:fix/autocomplete-trailing-space
Open

fix: don't append trailing space when selecting autocomplete group names (#3710)#3976
shengxinzhe wants to merge 1 commit intoconversejs:masterfrom
shengxinzhe:fix/autocomplete-trailing-space

Conversation

@shengxinzhe
Copy link
Copy Markdown
Contributor

Summary

Fixes #3710

When selecting a group name from the autocomplete dropdown with the mouse, a trailing space character was appended to the value. This made the saved group name different from the expected one (e.g., "Friends " instead of "Friends").

Root cause: replaceCurrentWord() in src/utils/form.js always appended a space after the autocompleted value. This is correct behavior for chat mentions (e.g., @username ) but wrong for form fields like comma-separated group names.

Fix: Add a configurable suffix option to the AutoComplete class and the converse-autocomplete component:

  • Default value: ' ' (preserves existing behavior for mentions)
  • Set to suffix="" on the groups autocomplete in the "Add Contact" and "Accept Contact Request" modals

Changes:

  • src/utils/form.js - Add optional suffix parameter to replaceCurrentWord()
  • src/shared/autocomplete/autocomplete.js - Add suffix config property, pass to replaceCurrentWord()
  • src/shared/autocomplete/component.js - Expose suffix as a Lit property
  • src/plugins/rosterview/modals/templates/add-contact.js - Set suffix="" on groups autocomplete
  • src/plugins/rosterview/modals/templates/accept-contact-request.js - Set suffix="" on groups autocomplete

…mes (conversejs#3710)

When selecting a group name from the autocomplete dropdown with the mouse,
a trailing space was appended to the value. This happened because
replaceCurrentWord() always added a space suffix, which is correct for
chat mentions but not for comma-separated fields like contact groups.

Add a configurable `suffix` option to the autocomplete component that
defaults to a space (preserving existing behavior for mentions) but can
be set to an empty string for fields where no trailing space is desired.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

contact's group name is altered when selecting it with the mouse from autocomplete

1 participant